//
//  HallViewController.m
//  CaiPiao
//
//  Created by zhoup on 16/5/24.
//  Copyright © 2016年 zhoup. All rights reserved.
//

#import "HallViewController.h"

@interface HallViewController ()


@property(nonatomic,weak) UIView *coverView;

@property(nonatomic,weak) UIImageView *imageView;
@end

@implementation HallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)leftBtnClicked:(UIButton *)sender {
    
    UIView *coverView = [[UIView alloc] init];
    [coverView setBackgroundColor:[UIColor blackColor]];
    NSLog(@"%@",NSStringFromCGRect(self.view.frame));
    coverView.frame = [UIScreen mainScreen].bounds;
    coverView.alpha = 0.5;
    self.coverView = coverView;
    
//    UIWindow *window = [UIApplication sharedApplication].keyWindow;
//    
//    [window addSubview:coverView];
    
    [self.tabBarController.view addSubview:coverView];
    
//    UIImageView *imageView1 = [[UIImageView alloc]init];
//    imageView1.image =[UIImage imageNamed:@""];
//    [imageView1 sizeToFit];
 
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cover"]];
    self.imageView = imageView;
    imageView.center = coverView.center;
    [self.tabBarController.view addSubview:imageView];
    imageView.userInteractionEnabled = YES;
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.y = 0;
    btn.width = 23;
    btn.height = 23;
    btn.x = imageView.image.size.width -btn.width;
    [btn setBackgroundColor:[UIColor redColor]];
    
    [btn setBackgroundImage:[UIImage imageNamed:@"ArenaHall_Close"] forState:UIControlStateNormal];
    
    [btn addTarget:self action:@selector(closeCover) forControlEvents:UIControlEventTouchUpInside];
    [imageView addSubview:btn];

    
    
}
#pragma mark -closeCover
-(void)closeCover
{
    //动画效果，让两个控件不可见，在移除
    [UIView animateWithDuration:1 animations:^{
        self.coverView.alpha = 0;
        self.imageView.alpha = 0;
    } completion:^(BOOL finished) {
        
        [self.imageView removeFromSuperview];
        [self.coverView removeFromSuperview];
    }];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
